Crate ic_event_hub_macros[][src]

Expand description

Various macro for IC canisters to enable event-based pub/sub

Usage:

// somewhere in your canister
implement_event_emitter!();
implement_become_event_listener!();
implement_stop_being_event_listener!();

...

#[derive(Event)]
struct Event {
    #[topic]
    pub a: u64,
    pub b: String,
}

emit(Event {
    a: 10,
    b: String::from("test")
});

Check the companion crate to see how a listener could start receiving events

Macros

Generates the canister endpoint to manually subscribe new event listeners

Generates the canister endpoint for another canister to subscribe to particular topics

Generates main functionality for event emitting

Generates the canister endpoint to list all the subscribed listeners

Generates the canister endpoint to manually unsubscribe previously subscribed listeners

Generates the canister endpoint for another canister to unsubscribe from particular topics

Derive Macros

Generates an implementation of ic_event_hub::types::IEvent trait for a given struct. Also generates a *Filter struct and an implementation of ic_event_hub::types::IEventFilter trait for that struct which can be used to filter topics while listening to the given event.